﻿function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = decodeURIComponent(hash[1]);
    }
    return vars;
}

//Init vars
var queryString = getUrlVars();
var SPHostUrl = queryString["SPHostUrl"];
var QRCodeText = queryString["QRCodeText"];
if (!QRCodeText) {
    QRCodeText = SPHostUrl;
}
var QRWidth = queryString["QRWidth"];
if (!QRWidth) {
    QRWidth = 200;
}
QRWidth = parseInt(QRWidth);

var QRHeight = queryString["QRHeight"];
if (!QRHeight) {
    QRHeight = 200;
}
QRHeight = parseInt(QRHeight);

var RenderMode = queryString["RenderMode"];
if (RenderMode == null) {
    RenderMode = "Canvas";
}
var cssFile = queryString["CustomCssFile"];
if (cssFile != null) {
    $('<link>').appendTo('head').attr({
        rel: 'stylesheet',
        type: 'text/css',
        href: cssFile
    });
}
